package adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.itboye.hutoubenjg.R;

import bean.measge_bean.WeiXiuiJiLuBean;
import util.utls.Const;
import util.utls.XImageLoader;

public class NoScrollGridAdapter extends BaseAdapter {

    /**
     * 上下文
     */
    private Context ctx;
    /**
     * 图片Url集合
     */
    WeiXiuiJiLuBean bean;

    public NoScrollGridAdapter(Context ctx, WeiXiuiJiLuBean bean) {
        this.ctx = ctx;
        this.bean = bean;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return bean.getList().size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = View.inflate(ctx, R.layout.item_gridview, null);
        ImageView imageView = (ImageView) view.findViewById(R.id.iv_image);

        Log.d("oaoaoaoaoaoa", bean.getList().get(position).getImages());
        if (bean.getList().get(position).getImages() == null || bean.getList().get(position).getImages() == "") {
            XImageLoader.load(Const.IMAGE_HEAD, imageView);
        } else {
            XImageLoader.load(Const.IMAGE_HEAD + bean.getList().get(position).getImages(), imageView);
        }
        return view;
    }

}
